/*
 * OLED.h
 *
 * Created: 24.03.2014 16:24:43
 *  Author: markus.hufschmid
 */ 


#ifndef OLED_H_
#define OLED_H_

#define Max_Column	0x7f			// 128-1
#define Max_Row		0x7f			// 128-1
#define	Brightness	0x0F

#define xData		PORTD

#define RD_HIGH		PORTA |= (1<<PA3)
#define RD_LOW		PORTA &= ~(1<<PA3)

#define WR_HIGH		PORTA |= (1<<PA4)
#define WR_LOW		PORTA &= ~(1<<PA4)

#define RES_HIGH	PORTA |= (1<<PA2)
#define RES_LOW		PORTA &= ~(1<<PA2)

#define CS_HIGH		PORTA |= (1<<PA0)
#define CS_LOW		PORTA &= ~(1<<PA0)

#define DC_HIGH		PORTA |= (1<<PA1)
#define DC_LOW		PORTA &= ~(1<<PA1)

#define BLACK	0x0000
#define WHITE	0xFFFF
#define RED		0xF800
#define GREEN	0x07E0
#define BLUE	0x001F
#define YELLOW	0xFFE0
#define GREY	0x8410
#define LT_GREY	0xC6F8
#define ORANGE	0xFD20
#define CYAN	0x07FF
#define MAGENTA	0xF81F
#define BROWN	0x9C60
#define SKY_BLUE	0x05FF


void draw_horizontal_line(uint8_t x_start, uint8_t y_start, uint8_t x_end, uint16_t color);
void draw_vertical_line(uint8_t x_start, uint8_t y_start, uint8_t y_end, uint16_t color);
void print_char_zoomed(char ascii_code, uint8_t x_start, uint8_t y_start, uint16_t color, uint16_t background, uint8_t zoom_factor);
void print_string_zoomed(char *Data_Pointer, uint8_t x_start, uint8_t y_start, uint16_t color, uint16_t background, uint8_t zoom_factor);

void Write_Command(unsigned char Data);
void Write_Data(unsigned char Data);
void Set_Column_Address(unsigned char a, unsigned char b);
void Set_Row_Address(unsigned char a, unsigned char b);
void Set_Write_RAM(void);
void Set_Read_RAM(void);
void Set_Remap_Format(unsigned char d);
void Set_Start_Line(unsigned char d);
void Set_Display_Offset(unsigned char d);
void Set_Display_Mode(unsigned char d);
void Set_Function_Selection(unsigned char d);
void Set_Display_On_Off(unsigned char d);
void Set_Phase_Length(unsigned char d);
void Set_Display_Enhancement(unsigned char d);
void Set_Display_Clock(unsigned char d);
void Set_VSL(unsigned char d);
void Set_GPIO(unsigned char d);
void Set_Precharge_Period(unsigned char d);
void Set_Precharge_Voltage(unsigned char d);
void Set_VCOMH(unsigned char d);
void Set_Contrast_Color(unsigned char a, unsigned char b, unsigned char c);
void Set_Master_Current(unsigned char d);
void Set_Multiplex_Ratio(unsigned char d);
void Set_Command_Lock(unsigned char d);
void Draw_Rectangle(unsigned char start_column, unsigned char end_column, unsigned char start_row, unsigned char end_row, unsigned char line_width, unsigned char color_high, unsigned char color_low);
void Fill_RAM(unsigned char a, unsigned char b);
void Fill_Block(unsigned char a, unsigned char b, unsigned char c, unsigned char d, unsigned char e, unsigned char f);
void Show_Font57(unsigned char a, unsigned char b, unsigned char c, unsigned char d, unsigned char e, unsigned char f);
void show_font_zoomed(unsigned char ascii_code, unsigned char color_high, unsigned char color_low, unsigned char start_x, unsigned char start_y, unsigned char zoom_factor);
void Show_Font20x28(unsigned char a, unsigned char b, unsigned char c, unsigned char d, unsigned char e, unsigned char f);
void Show_String(unsigned char a, char *Data_Pointer, unsigned char b, unsigned char c, unsigned char d, unsigned char e);
void Show_String_20x28(unsigned char a, char *Data_Pointer, unsigned char b, unsigned char c, unsigned char d, unsigned char e);
void show_string_zoomed(char *Data_Pointer, unsigned char color_high, unsigned char color_low, unsigned char start_x, unsigned char start_y, unsigned char zoom_factor);
void Sleep(unsigned char a);
void Set_Linear_Gray_Scale_Table(void);
void Set_Gray_Scale_Table(void);
void OLED_Init(void);


#endif /* OLED_H_ */